#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // QMenuBar* menuBar = new QMenuBar;
    QMenuBar* menuBar = this->menuBar();
    this->setMenuBar(menuBar); // 设置菜单栏

    QMenu* menu = new QMenu("菜单");
    menuBar->addMenu(menu);
    // menu->setIcon(":"); // 可以给菜单设置图标
    QMenu* menuChild = new QMenu("子菜单");
    menu->addMenu(menuChild); // 添加子菜单

    QAction* action1 = new QAction("菜单项1");
    QAction* action2 = new QAction("菜单项2");
    // action1->setIcon(); // 同理

    menu->addAction(action1);
    menuChild->addAction(action2);
}

MainWindow::~MainWindow()
{
    delete ui;
}

